<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改品牌</title>
</head>
<body>
<div id="app">
    <h3>修改品牌</h3>
    <form>
        品牌名称：<input name="brandName" value="" id="brandName" v-model="brand.brandName"><br>
        企业名称：<input name="companyName" value="" id="companyName"  v-model="brand.companyName"><br>
        排序：<input name="ordered" value="" id="ordered"  v-model="brand.ordered"><br>
        描述信息：<textarea rows="5" cols="20" name="description" id="description"  v-model="brand.description"></textarea><br>
        状态：
        <input type="radio" name="status" value="0" v-model="brand.status">禁用
        <input type="radio" name="status" value="1" v-model="brand.status">启用<br>
        <input type="button" value="修改" @click="updateBrand()">
    </form>
</div>

<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data:{
            brand: {}
        },
        mounted(){
            let id = window.sessionStorage.getItem("id")
            // 向后端请求数据
            axios.get('http://localhost:8080/SelectBrandServlet?brandId=' + id)
                .then(res => {
                    this.brand = res.data
                })
        },
        methods: {
            updateBrand() {

                // 发送ajax请求
                axios.post('http://localhost:8080/UpdateBrandServlet',this.brand)
                    .then(res => {
                    alert(res.data.msg)
                    // 跳转到 index.html
                    window.location.href = '/index.html'
                })
            }
        }
    })

</script>
</body>
</html>